﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShoppingLists.Core
{
    public class ShoppingList
    {
        public List<Product> Products { get; private set; }

        public ShoppingList()
        {
            Products = new List<Product>();
        }

        public void addProduct(String product)
        {
             //Ensure to not add the same object twice
            if (Products.Where(x => x.ProductName == product).Any())
            {
                //throw exception
            }
            else
            {
                Products.Add(new Product(product));
            }
        }

        public void removeProduct(String product)
        {
            Products.Remove(Products.Single(x => x.ProductName == product));
        }

        public int numberOfProducts()
        {
            return Products.Count;
        }
    }
}
